package com.gadgets.framework.fm03.controller;

import com.gadgets.framework.common.dto.HttpBaseResp;
import com.gadgets.framework.common.dto.Pagination;
import com.gadgets.framework.common.exception.GadgetsServiceException;
import com.gadgets.framework.fm03.dto.BusiNodeQueryDTO;
import com.gadgets.framework.fm03.pojo.BusiNodeInfo;
import com.gadgets.framework.fm03.service.IBusiNodeManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author xiujunqing
 * @version V1.1.0
 * @data 2021-10-14
 * @moduel com.gadgets.framework.flow.controller
 */
@RestController
@RequestMapping(method = {org.springframework.web.bind.annotation.RequestMethod.POST,org.springframework.web.bind.annotation.RequestMethod.GET},value = "/fm03")
public class BusiNodeManagerController {

    @Autowired
    @Qualifier(value = "busiNodeManagerServiceImpl")
    private IBusiNodeManagerService nodeManagerService;

    /**
     * 新增流程节点信息
     * @param request                       请求信息
     * @param response                      应答信息
     * @param nodeInfo                      节点信息
     * @return                              应答信息
     * @throws GadgetsServiceException      异常信息
     */
    public HttpBaseResp<Object> addBusiNodeInfo(HttpServletRequest request, HttpServletResponse response, BusiNodeInfo nodeInfo) throws GadgetsServiceException {
        nodeManagerService.addBusiNodeInfo(nodeInfo);
        return new HttpBaseResp<>();
    }

    /**
     * 条件分页查询流程节点信息
     * @param request                       请求信息
     * @param response                      应答信息
     * @param queryDTO                      查询条件
     * @param pagination                    分页条件
     * @return                              查询结果
     * @throws GadgetsServiceException      异常信息
     */
    public HttpBaseResp<BusiNodeInfo> queryBusiNodeByConditionAndPaging(HttpServletRequest request, HttpServletResponse response, BusiNodeQueryDTO queryDTO, Pagination pagination) throws GadgetsServiceException{
        List<BusiNodeInfo> list = nodeManagerService.selectBusiNodeByCondition(queryDTO, pagination);
        return new HttpBaseResp<BusiNodeInfo>(list,pagination);
    }

}
